package com.citybrain.rnapp;

import java.util.Arrays;
import java.util.List;

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;

import com.citybrain.rnapp.modules.ReactNativeQRCodePackage;
import com.citybrain.rnapp.BuildConfig;
import com.RNFetchBlob.RNFetchBlobPackage;
import org.devio.rn.splashscreen.SplashScreenReactPackage;
import com.BV.LinearGradient.LinearGradientPackage;
import com.citybrain.rnapp.modules.ReactNativeAccToPcmPackage;
import com.citybrain.rnapp.modules.ReactNativeReLoadPackage;
import com.facebook.react.ReactApplication;
import cn.jystudio.local.barcode.recognizer.LocalBarcodeRecognizerPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.github.yamill.orientation.OrientationPackage;
import com.horcrux.svg.SvgPackage;
import com.imagepicker.ImagePickerPackage;
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import com.rnim.rn.audio.ReactNativeAudioPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.zmxv.RNSound.RNSoundPackage;
import org.reactnative.camera.RNCameraPackage;

public class MainApplication extends Application implements ReactApplication {

    static MainApplication instance;

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        @Override
        public boolean getUseDeveloperSupport() {
            return BuildConfig.DEBUG;
        }

        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage> asList(new MainReactPackage(),
            new LocalBarcodeRecognizerPackage(),
            new RNFetchBlobPackage(),
            new ReactNativeQRCodePackage(),
            new SplashScreenReactPackage(), new RNCameraPackage(),
                    new ReactNativeReLoadPackage(),new ReactNativeAccToPcmPackage(),
                new RNSoundPackage(), new ReactNativeAudioPackage(), new SvgPackage(), new RNGestureHandlerPackage(),
                new AsyncStoragePackage(), new OrientationPackage(), new ImagePickerPackage(),
                new LinearGradientPackage());
        }

        @Override
        protected String getJSMainModuleName() {
            return "index";
        }
    };

    @Override
    public ReactNativeHost getReactNativeHost() {
        return mReactNativeHost;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        SoLoader.init(this, /* native exopackage */ false);
    }

  @Override
  protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
  }

    public static MainApplication getInstance()
    {
        return instance;
    }

}
